//
//  TTRequest.h
//  WxIOSReaderForiPhone
//
//  Created by apan on 17/5/11.
//  Copyright © 2017年 anzeinfo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "TTInterfaceModel.h"
#import "AFNetworking.h"

//网络配置
#define HTTP_TIME_OUT       20.0f
#define HTTP_REQUEST_TYPE   @"POST"

NS_ASSUME_NONNULL_BEGIN
/**
 API请求类(具体的API请求基于该类派生实现单例类，给业务层提供api调用服务)
 */
@interface TTRequest : NSObject
@property (nonatomic) AFHTTPSessionManager *manager;
/**
 对NSString进行Base64加密
 */
-(NSString*) string2Base64String:(NSString*)_string;

/**
 对NSData进行Base64加密
 */
-(NSString*) data2Base64String:(NSData*)_data;

/**
 组装Get方式的URL
 
 @param url url RequestUrl
 @param param param description
 @return return value description
 */
-(NSString*)getUrlByParam:(NSString*)url
                withParam:(NSDictionary* _Nullable)param;

/**
 发起异步网络请求

 @param url url description
 @param postData postData为nil时进行get请求，否则为post请求
 @param modal modal description
 @param onSuccess onSuccess description
 @param onFail onFail description
 */
-(void)asynRequestServerAndParser:(NSString*)url
                     withPostData:(NSDictionary* _Nullable)postData
                  withParserModal:(TTInterfaceModel*)modal
                      withSuccess:(void(^)(TTInterfaceModel* model))onSuccess
                         withFail:(void(^)(NSString* error))onFail;
@end
NS_ASSUME_NONNULL_END
